package com.nf.dbutils.handlers;

import com.nf.dbutils.RowProcessor;

import java.sql.ResultSet;
import java.sql.SQLException;

public class ArrayHandler extends AbstractResultSetHandler<Object[]>{
    private static final Object[] EMPTY_OBJECT=new Object[0];

    public ArrayHandler() {
    }

    public ArrayHandler(RowProcessor rowProcessor) {
        super(rowProcessor);
    }
    @Override
    public Object[] handle(ResultSet rs) throws SQLException {
        return rs.next()? rowProcessor.toArray(rs) : EMPTY_OBJECT;
    }
}
